#ifndef _IOOPERATIONIMPL_H_
#define _IOOPERATIONIMPL_H_

#include "stdafx.h"


#include <io/ioperation.h>


class CIoOperationImpl :	public	IIoOperation,
							public	CUnknownImp

{
public:
	CIoOperationImpl(void);
	virtual ~CIoOperationImpl(void);
	UNKNOWN_IMP1(IIoOperation);

	void BindEvent(IIoOperationEvents *pEvents);
	//////////////////////////////////////////////////////////////////////////
	//IIoOperation
	std_method(SetOpType)(optype op);
	std_method_(optype, GetOpType)();
	std_method(SetId)(ULONG lId);
	std_method_(ULONG, GetId)();
	std_method(SetResult)(ERROR_CODE lErrorCode,
		ULONG lTransferedBytes);
	std_method(GetResult)(ERROR_CODE *pErrorCode,
		ULONG *pTransferedBytes);
	std_method(SetIoParam)(ULONG lIoStartPos, ULONG lIoExpectBytes);
	std_method(GetIoParam)(ULONG* pIoStartPos, ULONG* pIoExpectBytes);
	std_method(AttachIoBuf)(BUFFER_PTR buf,ULONG lIoStartPos, ULONG lIoExpectBytes);
	std_method(SetIoLen)(ULONG lIoSize);
	std_method_(ULONG, GetIoLen)();
	std_method(ClearBuf)();
	std_method_(BUFFER_PTR, GetIo)(ULONG Pos);

	std_method(SetResultInterface)(IBase* lOperationPos);
	std_method(GetResultInterface)(IBase** pOperationPos);
	std_method(Cancel)();
	std_method(SetBind)(os_io_fd fd);
	std_method_(os_io_fd*, GetBind)();
	std_method_(const char*, GetAddress)();
	std_method(SetAddress)(const char* addr);
	std_method_(unsigned long, GetConPort)();
	std_method(SetConPort)(unsigned long uport);
	std_method(Post)();
	std_method(SetAsynRW)(bool bstart);
	std_method_(bool, IsAsynRWThread)();
	std_method(SetMultiThread)(bool bstart);
	std_method_(bool, GetMultiThread)();

public:
	IIoOperationEvents*								m_pEvent;
private:
	os_io_fd										m_fd;
	optype											m_Opt;
	bool											m_bAsynrw;
	bool											m_MultiThread;
	ERROR_CODE										m_Errorcode;
	ULONG											m_pTransferedBytes;
	ULONG											m_id;
	BUFFER_SIZE										m_lIoStartPos;
	BUFFER_SIZE										m_lIoExpectBytes;
	BUFFER_SIZE										m_pBufLen;
	sentry<unsigned char*, default_array_sentry>	m_pBuf;
	_lComPtr<IBase>									m_pIResultBase;

};






#endif